<?php require '../public/system/headers/headers.php';?>
<?php echo $this->headLink()->appendStylesheet($this->websiteUrl . 'system/css/seotoaster.css'); ?>
<?php echo $this->headScript()->appendFile($this->websiteUrl . 'system/js/jquery/jquery.js'); ?>
<script type="text/javascript">

$(document).ready(function(){
        
    $('legend.option').click(function(){
        var value = $(this).children('input').val();
        $(this).children('input').attr('checked','checked');
        $('div.fieldset-content').each(function(){
                    $(this).removeClass('active');
                });
        $(this).next('div.fieldset-content').addClass('active');
    });

    //check if there no error data - allow subbit
    $('form#saveconfig').submit(function(){
        if ($('.er').size() > '0') {
            $('#warning').show();
            return false;
        } else {
            $('#warning').hide();
            return true;
        }

    });
    //check if the field have data with expected format
    $("input.numonly").change(function(){
        var value  = $(this).val();
        var regexp = /^(\d+(\.\d+)?)?$/;
        if (!regexp.test(value)){
            $(this).addClass('er');
            $("#show-warning").val('true');
            $('#warning').show();
            
        } else {
            $(this).removeClass('er');
            if ($('.er').size() == '0') $('#warning').hide();
        }
    });

    //prevent input non-digits
    $("input.numonly").keypress(function(event){
        var key = (typeof event.charCode == 'undefined' ? event.keyCode : event.charCode);
        if (event.ctrlKey || event.altKey || key < 32) return true;
        key = String.fromCharCode(key);

        return /[\d\.]/.test(key);
    });
});
</script>
<div id="seotoaster" class="shoppingconfig">
<div class="admineditwhat">{%Shipping Config%} </div>
<div class="close_window" onclick="parent.tb_remove();"></div>
<?php if ($this->error) : ?>
<div id="message" class="errors" style="background-color:red;" onclick="this.style.display='none';">{%Corrupted data detected. Configuration not updated%}.</div>
<?php endif; ?>
<?php if ($this->update) : ?>
<div id="message" class="errors" style="background-color:green;" onclick="this.style.display='none';">{%Configuration updated%}.</div>
<?php endif; ?>
<div id="list_images"></div>
<form action="<?php echo $this->websiteUrl; ?>sys/backend_shipping/config/" name="saveconfig" id="saveconfig" method="post" enctype="multipart/form-data">
    
    <div class="block1">
        
            <fieldset><legend>General Options</legend>
                <label>{%Notice for users%}:</label>
                <textarea style="height:60px" id="shipping-general-notice" name="shipping-general[notice]"><?php echo $this->shippingGeneral['notice']?></textarea>
                <label>Enable:&nbsp;</label>
                <input type="checkbox" name="shipping-general[couponing]" disabled="disabled"/><label>{%Couponing%}?</label>
                <input type="checkbox" name="shipping-general[gifting]" <?php echo ($this->shippingGeneral['gifting'] == 'on' ? 'checked="checked"' : ' ');?>/><label>{%Gifting%}?</label>
            </fieldset>
        
        <fieldset id="#shipping-options"><legend>{%Shipping Options%}</legend>
            <fieldset><legend class="option"><input type="radio" name="shipping-type" value="pickup" <?php echo ($this->shippingType=='pickup'?' checked="checked"':'');?>/>&nbsp;{%Pickup: (No shipping)%}</legend>
                <div class="fieldset-content <?php echo ($this->shippingType=='pickup'?'active':'');?>">
                    <label style="display: block;margin: 10px; text-align: justify">When this option is checked user will not be able to fill the shipping address on checkout stage.</label>
                </div>
            </fieldset>
            <fieldset><legend class="option"><input type="radio" name="shipping-type" value="amount" <?php echo ($this->shippingType=='amount'?' checked="checked"':'');?>/>&nbsp;{%Shipping per order amount%}</legend>
            <div class="fieldset-content <?php echo ($this->shippingType=='amount'?'active':'');?>">
                
                <div class="sh-1-col" style="float:left;width:33%;text-align:center;">
                    <label>{%Order amount%}...&nbsp;</label><br/>
                    <label>{%up to%}&nbsp;</label><input class="incolumn numonly" name="shipping-amount[1][limit]" id="sh-amount-1-limit" type="text" value="<?php echo $this->shippingAmount[1]['limit'];?>" /><br/>
                    <label>{%up to%}&nbsp;</label><input class="incolumn numonly" name="shipping-amount[2][limit]" id="sh-amount-2-limit" type="text" value="<?php echo $this->shippingAmount[2]['limit'];?>" /><br/>
                    <label>{%over%}&nbsp;</label><input class="incolumn numonly" name="shipping-amount[3][limit]" id="sh-amount-3-limit" type="text" value="<?php echo $this->shippingAmount[3]['limit'];?>" /><br/>
                </div>

                <div class="sh-2-col" style="float:left;width:33%;text-align:center;">
                    <label>{%National%}</label>
                    <input class="incolumn numonly" name="shipping-amount[1][national]" id="sh-amount-1-national" type="text" value="<?php echo $this->shippingAmount[1]['national'];?>" /><label>&nbsp;<?php echo $this->currency;?></label>
                    <input class="incolumn numonly" name="shipping-amount[2][national]" id="sh-amount-2-national" type="text" value="<?php echo $this->shippingAmount[2]['national'];?>" /><label>&nbsp;<?php echo $this->currency;?></label>
                    <input class="incolumn numonly" name="shipping-amount[3][national]" id="sh-amount-3-national" type="text" value="<?php echo $this->shippingAmount[3]['national'];?>" /><label>&nbsp;<?php echo $this->currency;?></label>
                </div>

                <div class="sh-3-col" style="float:left;width:33%;text-align:center;">
                    <label>{%International%}</label>
                    <input class="incolumn numonly" name="shipping-amount[1][international]" id="sh-amount-1-international" type="text" value="<?php echo $this->shippingAmount[1]['international'];?>" /><label >&nbsp;<?php echo $this->currency;?></label>
                    <input class="incolumn numonly" name="shipping-amount[2][international]" id="sh-amount-2-international" type="text" value="<?php echo $this->shippingAmount[2]['international'];?>" /><label >&nbsp;<?php echo $this->currency;?></label>
                    <input class="incolumn numonly" name="shipping-amount[3][international]" id="sh-amount-3-international" type="text" value="<?php echo $this->shippingAmount[3]['international'];?>" /><label >&nbsp;<?php echo $this->currency;?></label>
                </div>
                <p style="margin: 2px 0px 0px 5px;float:left"><label>{%Free shipping for order over%}: </label><br />
                    <input type="text" class="numonly" name="shipping-general[free-shipping-over]" id="sh-free-over" style="display: inline; float: none; width: 90px;height:24px" value="<?php echo $this->shippingGeneral['free-shipping-over'];?>"/>
                    <label>&nbsp;<?php echo $this->currency;?>&nbsp;{%for%}&nbsp;</label>
                    <select name="shipping-general[free-shipping-options]" id="sh-free-over-options" style="display: inline; float: none; width: 100px">
                           <option value="">{%select%}</option>
                           <option value="national" <?php echo ($this->shippingGeneral['free-shipping-options']=='national'?' selected="selected"':''); ?>>{%National%}</option>
                           <option value="international" <?php echo ($this->shippingGeneral['free-shipping-options']=='international'?' selected="selected"':''); ?>>{%International%}</option>
                           <option value="both" <?php echo ($this->shippingGeneral['free-shipping-options']=='both'?' selected="selected"':''); ?>>{%Both%}</option>
                    </select>
                    <label>delivery</label>
                </p>
            </div>
                
            </fieldset>
            <fieldset><legend class="option"><input type="radio" name="shipping-type" value="weight" <?php echo ($this->shippingType=='weight'?' checked="checked"':'');?>/>&nbsp;{%Shipping per total weight%}</legend>
            <div class="fieldset-content <?php echo ($this->shippingType=='weight'?' active':'');?>">
                
                <p style="clear: both; float:none;"><label>{%Weight Unit%}:&nbsp;</label>
                    <select name="shipping-general[weight-units]" id="sh-weight-unit" style="display:inline;float:none;width: 100px;">
                        <option value="" <?php echo ($this->shippingGeneral['weight-units']==''?' selected="selected"':''); ?>>{%select%}</option>
                        <option value="Kg" <?php echo ($this->shippingGeneral['weight-units']=='Kg'?' selected="selected"':''); ?>>Kilogram</option>
                        <option value="lbs" <?php echo ($this->shippingGeneral['weight-units']=='lbs'?' selected="selected"':''); ?>>Pounds</option>
                    </select>
                </p>
                <div class="sh-1-col" style="float:left;width:33%;text-align:center;">
                    <label>{%Order weight%}...&nbsp;</label><br/>
                    <label>{%up to%}&nbsp;</label><input class="incolumn numonly" name="shipping-weight[1][limit]" id="sh-weight-1-limit" type="text" value="<?php echo $this->shippingWeight[1]['limit'];?>" /><br/>
                    <label>{%up to%}&nbsp;</label><input class="incolumn numonly" name="shipping-weight[2][limit]" id="sh-weight-2-limit" type="text" value="<?php echo $this->shippingWeight[2]['limit'];?>" /><br/>
                    <label>{%over%}&nbsp;</label><input class="incolumn numonly" name="shipping-weight[3][limit]" id="sh-weight-3-limit" type="text" value="<?php echo $this->shippingWeight[3]['limit'];?>" /><br/>
                </div>

                <div class="sh-2-col" style="float:left;width:33%;text-align:center;">
                    <label>{%National%}</label>
                    <input class="incolumn numonly" name="shipping-weight[1][national]" id="sh-weight-1-national" type="text" value="<?php echo $this->shippingWeight[1]['national'];?>" /><label>&nbsp;<?php echo $this->currency;?></label>
                    <input class="incolumn numonly" name="shipping-weight[2][national]" id="sh-weight-2-national" type="text" value="<?php echo $this->shippingWeight[2]['national'];?>" /><label>&nbsp;<?php echo $this->currency;?></label>
                    <input class="incolumn numonly" name="shipping-weight[3][national]" id="sh-weight-3-national" type="text" value="<?php echo $this->shippingWeight[3]['national'];?>" /><label>&nbsp;<?php echo $this->currency;?></label>
                </div>

                <div class="sh-3-col" style="float:left;width:33%;text-align:center;">
                    <label>{%International%}</label>
                    <input class="incolumn numonly" name="shipping-weight[1][international]" id="sh-weight-1-international" type="text" value="<?php echo $this->shippingWeight[1]['international'];?>" /><label>&nbsp;<?php echo $this->currency;?></label>
                    <input class="incolumn numonly" name="shipping-weight[2][international]" id="sh-weight-2-international" type="text" value="<?php echo $this->shippingWeight[2]['international'];?>" /><label>&nbsp;<?php echo $this->currency;?></label>
                    <input class="incolumn numonly" name="shipping-weight[3][international]" id="sh-weight-3-international" type="text" value="<?php echo $this->shippingWeight[3]['international'];?>" /><label>&nbsp;<?php echo $this->currency;?></label>
                </div>
            </div>
            </fieldset>
            <!--Moved to another "Tax Configuration" screen
            <fieldset><legend>{%Taxes configuration%}</legend>
                <p><label>{%Tax%}: </label><b style="float:right;margin:4px 0px 0px 0px;">%</b><input type="text" name="tax" id="tax" style="margin-right:5px;width:185px;" value="<?php echo $this->shippingConfig['tax']; ?>" /></p>
            </fieldset>
            -->

            <input type="hidden" name="show-warning" id="show-warning" value="false" />
            <div id="warning">
                <p style="margin-top: -4px">
                    Value you entered in some field above have wrong type. Please enter value only in numerical format (e.g. 133.25).
                </p>
            </div>
        </fieldset>
		
    </div><!--  end block2 div -->
   	<input type="submit" name="submit" value="{%Save%}" class="formsubmit"/>

</form>

</div>